package com.zijin;

import com.zijin.Dao.DeptMapper;
import com.zijin.entity.Dept;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.util.List;


public class App4 {
    public static void main(String[] args) {
        SqlSessionFactory ssf = new SqlSessionFactoryBuilder().build(
                App.class.getClassLoader().getResourceAsStream("mybatisConf.xml"));
//打开一个会话 ，会话会占用资源，不需要时要关闭
        SqlSession ss = ssf.openSession();
        //获得DeptMapper接口实现类
        DeptMapper deptMapper = ss.getMapper(DeptMapper.class);//向上造型，session.getMapper() 方法内部产生了DeptMapper的实现类
        //增加部门
        int result=deptMapper.addDept2(new Dept(6,"swy","hh"));

        //增加id为6
        //int result=deptMapper.addDept1(6);

        //查询Dept的所有数据
        //List<Dept> list=deptMapper.selectAllDept();
        //只显示一行
        System.out.println(result);
    }
}